package net.jiastudy.core.handler;

import java.util.Date;

import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.mapper.MetaObjectHandler;

@Component
public class MyMetaObjectHandler extends MetaObjectHandler {

	@Override
	public void insertFill(MetaObject metaObject) {
		Object createDate = getFieldValByName("createDate", metaObject);
		if (null == createDate) {
			setFieldValByName("createDate", new Date(), metaObject);
		}
	}

	@Override
	public void updateFill(MetaObject metaObject) {
		setFieldValByName("lastModified", new Date(), metaObject);
	}
}
